﻿Imports System.Windows.Forms.DataVisualization.Charting
Imports System.Data
Imports System.Collections.Generic

Public Class BarChart
    Dim table As New DataTable("Cost")
    Private Sub CreateDataTable(ByVal Cost As List(Of Integer))
        Dim Round As DataColumn = New DataColumn("Round")
        Dim CostColumn As DataColumn = New DataColumn("Cost")
        table.Columns.Add(Round)
        table.Columns.Add(CostColumn)
        Dim k As Integer = 0
        For Each i As Integer In Cost
            Dim row As DataRow = table.NewRow
            row.Item("Round") = k
            k = k + 1
            row.Item("Cost") = i
            table.Rows.Add(row)
        Next i

    End Sub


    Public Sub New(ByVal Cost As List(Of Integer))

        ' This call is required by the designer.
        InitializeComponent()

        CreateDataTable(Cost)
        ' Add any initialization after the InitializeComponent() call.
        Dim ChartArea1 As ChartArea = New ChartArea()
        Dim Legend1 As Legend = New Legend()
        Dim Series1 As Series = New Series()
        Dim Chart1 = New Chart()
        Me.Controls.Add(Chart1)

        ChartArea1.Name = "ChartArea1"
        Chart1.ChartAreas.Add(ChartArea1)
        Legend1.Name = "Legend1"
        Chart1.Legends.Add(Legend1)
        Chart1.Location = New System.Drawing.Point(13, 13)
        Chart1.Name = "Chart1"
        Series1.ChartArea = "ChartArea1"
        Series1.Legend = "Legend1"
        Series1.Name = "Series1"
        Chart1.Series.Add(Series1)
        Chart1.Size = New System.Drawing.Size(1000, 400)
        Chart1.TabIndex = 0
        Chart1.Text = "Chart1"

        Chart1.Series("Series1").XValueMember = "Round"
        Chart1.Series("Series1").YValueMembers = "Cost"

        Chart1.DataSource = table
        Me.Show()

    End Sub

End Class